<?php
	require_once (dirname(__FILE__) . '/phptal/PHPTAL.php');
	require_once (dirname(__FILE__) . '/config/config.php');
	require_once (dirname(__FILE__) . '/viae/templateBuilder.php');
	require_once (dirname(__FILE__) . '/viae/dbhelper.php');
	
	$configurations = getConfiguration();

	$configs = array();
	
	foreach($configurations as $configuration){
		$input = new GivenCanvasConfiguration();
		$input->extendedCanvasWidthCm = $configuration["width"];
		$input->extendedCanvasHeightCm = $configuration["height"];
		$input->bleedXLCm = $configuration["bleed_xl"];
		$input->bleedXRCm = $configuration["bleed_xr"];
		$input->bleedYTCm = $configuration["bleed_yt"];
		$input->bleedYBCm = $configuration["bleed_yb"];
		$input->dpi = $configuration["dpi"];
		$input->price = $configuration["price"];
		array_push($configs, $input);
	}
	
	$input = new GivenCanvasConfiguration();
	$input->extendedCanvasWidthCm = 5;
	$input->extendedCanvasHeightCm = 12;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 100;
	$input->price = "50";
	array_push($configs, $input);

	$template = buildTemplate($configs, dirname(__FILE__) . '/index.html');
	$imageUploadTemplate = new PHPTAL(dirname(__FILE__) . '/templates/imageUploadDialog.template.html');
	$toolboxTemplate = new PHPTAL(dirname(__FILE__) . '/templates/toolboxDialog.template.html');
	$explanationTemplate = new PHPTAL(dirname(__FILE__) . '/templates/explanationDialog.template.html');
	
	try {
		echo $imageUploadTemplate -> execute();
		echo $toolboxTemplate -> execute();
		echo $explanationTemplate -> execute();
		
		echo '<script id="workspace_image_template" type="text/x-jquery-tmpl">';
		echo '<img id="${image_id}" src="${image_url}" width="${image_width}" height="${image_height}" style="border: none;"/>';
		//echo '<img id="${image_id}" src="${image_url}" width="100" height="100" style="border: none; max-width:300px;"/>';
		echo '</script>';
		
		echo $template -> execute();
	} catch (Exception $e) {
		echo $e;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	/*
	
	$input = new GivenCanvasConfiguration();
	$input->extendedCanvasWidthCm = 10;
	$input->extendedCanvasHeightCm = 5;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 100;
	$input->price = "50";
	array_push($configs, $input);
	
	$input = new GivenCanvasConfiguration();
	 $input->extendedCanvasWidthCm = 5;
	$input->extendedCanvasHeightCm = 5;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 100;
	$input->price = "50";
	array_push($configs, $input);
	
	$input = new GivenCanvasConfiguration();
	$input->extendedCanvasWidthCm = 20;
	$input->extendedCanvasHeightCm = 20;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 50;
	$input->price = "50";
	array_push($configs, $input);
	
	$input = new GivenCanvasConfiguration();
	$input->extendedCanvasWidthCm = 25;
	$input->extendedCanvasHeightCm = 50;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 100;
	$input->price = "50";
	array_push($configs, $input);
	
	$input = new GivenCanvasConfiguration();
	$input->extendedCanvasWidthCm = 100;
	$input->extendedCanvasHeightCm = 100;
	$input->bleedXLCm = 1;
	$input->bleedXRCm = 1;
	$input->bleedYTCm = 1;
	$input->bleedYBCm = 1;
	$input->dpi = 100;
	$input->price = "50";
	array_push($configs, $input);*/
?>


